public package wator.util;

import java.util.Vector;

public class Tools {

	
	public static String extractAgentType(String str)
	{
		String[] temp=str.split("@");
		String[] temp2=temp[0].split("wator.model.agents.");
		String type=temp2[1];
		return type;
	}
	
	public static String parseStrategy(Vector<Integer> parameters,String key)
	{
		if(key.contains("(") && key.contains(")") && !key.contains("()"))
		{
			String[] tmp=key.split("\\(");
			String[] tmp1=tmp[1].split("\\)");
			String argv=tmp1[0];
			for(String paramstr : argv.split(","))
				parameters.add(new Integer(paramstr));
			return tmp[0];
		}
		else if(key.contains("()"))
		{
			return key.split("\\(\\)")[0];
		}
		else return key;
	}
	
	public static void updateProgress(double progressPercentage)
	{
	    final int width = 50; // progress bar width in chars

	    System.out.print("\r [");
	    int i = 0;
	    for (; i <= (int)(progressPercentage*width); i++) {
	      System.out.print(".");
	    }
	    for (; i < width; i++) {
	      System.out.print(" ");
	    }
	    System.out.print("]");
	}

}
